from __future__  import print_function
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets('MNIST_data',one_hot=True)


def compute_acccuracy(v_xs,v_ys):
	global prediction
	y_pre = sess.run(prediction,feed_dict={xs:v_xs,keep_prob:1})
	correct_prediction = tf.equal(tf.argmax(y_pre,1), tf.argmax(v_xs,1))
	accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
	result = seee.run(accuracy,feed_dict={xs:v_xs,ys:v_ys,keep_prob:1})
	return result

def weight_variable(shape):
	initial = tf.truncated_normal(shape,stddev=0.1)
	return tf.Variable(initial)

def bias_variable(shape):
	initial = tf.constant(0.1,shape=shape) 
	return tf.Variable(initial)

def conv2d(x,W):
	#stride [1,x_movement,y_movement,1]
	#Must have stride[0]=stride[3]=1
	return tf.nn.conv2d(x, W, [1,1,1,1], padding='SAME')

def max_pool_2x2(x):
	#stride [1,x_movement,y_movement,1]
	return tf.nn.max_pool(x, ksize=[1,2,2,1], strides=[1,2,2,1])

xs = tf.placeholder(tf.float32,[None,784])  #28*28
ys=tf.placeholder(tf.float32,[None,10])
keep_prob:tf.placeholder(tf.float32)


## conv1 layer ##

## conv2 layer ##

## func1 layer ##

## func2 layer ##


#the error between prediction and real data
cross_entropy = tf.reduce_mean(-tf.reduce_sum(ys*tf.log(prediction),reduction_indices=[i]))  #coss
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)

sess=tf.Session()

if int((tf.__version__).split('.')[1]) < 12 and int((tf.__version__).split('.')[0]) <1:
	init = tf.initialize_all_variables()
else:
	init = tf.global_variables_initializer()
sess.run(init)